<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one or more
  ~ contributor license agreements.  See the NOTICE file distributed with
  ~ this work for additional information regarding copyright ownership.
  ~ The ASF licenses this file to You under the Apache License, Version 2.0
  ~ (the "License"); you may not use this file except in compliance with
  ~ the License.  You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Saga-booking-demo</title>

    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>

    <script type="text/javascript">
        function testCase1() {
            $.post("http://127.0.0.1:8083/booking/test/2/2", function(data) {
                var msg = data;
                $("#booking_result_1").html(msg);
            });
        }

        function testCase2() {
            $.post("http://127.0.0.1:8083/booking/test/3/2", function(data) {
                var msg = data;
                $("#booking_result_2").html(msg);
            })
            .fail(function(data) {
                alert("The transaction is failed");
                $("#booking_result_2").html("<li>" + JSON.stringify(data) + "</li>");
            });
        }

        function room_booking_result() {
            $.get("http://127.0.0.1:8081/bookings", function(data) {
                var msg = "<li>" + JSON.stringify(data) + "</li>";
                $("#room_list").html(msg);
            });
        }

        function car_booking_result() {
            $.get("http://127.0.0.1:8082/bookings", function(data) {
                var msg = "<li>" + JSON.stringify(data) + "</li>";
                $("#car_list").html(msg);
            });
        }
    </script>
</head>
<body>
<p>Test cases of Sage booking demo:</p>
<p>Case 1. <a href="javascript:void(0);" onclick="testCase1();">[Booking 2 rooms and 2 cars, will done successfully]</a> </p>
<p>
    Booking result: <span id="booking_result_1">###</span><br>
</p>
<br>
<p>Case 2. <a href="javascript:void(0);" onclick="testCase2();">[Booking 3 rooms and 2 cars, hotel order service will failed.]</a> </p>
<p>
    Booking result: <span id="booking_result_2">###</span><br>
</p>
<br>
<p><a href="javascript:void(0);" onclick="room_booking_result();">[Query the room booking result]</a> </p>
<p>
    Room booking list:<br>
<ul>
    <li id="room_list">
        #Name, Amount, Confirm status, Cancel Status
    </li>
</ul>
</p>
<br>
<p><a href="javascript:void(0);" onclick="car_booking_result();">[Query the car booking result]</a> </p>
<p>
    Car booking list:<br>
<ul>
    <li id="car_list">
        #Name, Amount, Confirm status, Cancel Status
    </li>
</ul>
</p>
</body>
</html>
